/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BLO;

import DAO.PersonDAO;
import DTO.PersonDTO;
import Util.ConnectionUtil;
import java.sql.Connection;
import java.util.ArrayList;

/**
 *
 * @author Arturia
 */
public class PersonBLO {
    private Connection con;

    public ArrayList<PersonDTO> getAllPerson() {
        ArrayList<PersonDTO> list = new ArrayList<PersonDTO>();
        try {
            con = ConnectionUtil.getConnection();
            list = PersonDAO.LoadDatabase(con, null);
            
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }

    public boolean insertPerson(PersonDTO person){
        con = ConnectionUtil.getConnection();
        if (PersonDAO.insert(con, person) > 0) {
            return true;
        }
        return false;
    }

    public boolean updatePerson(PersonDTO person){
        con = ConnectionUtil.getConnection();
        if (PersonDAO.update(con, person) > 0) {
            return true;
        }
        return false;
    }

    public boolean deletePerson(String deletePerson){
        con = ConnectionUtil.getConnection();
        if(PersonDAO.delete(con, deletePerson) > 0){
            return true;
        }
        return false;
    }
}
